﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VioletDevelopmentLaboratory.Net.Web;
using VioletDevelopmentLaboratory.Net.Web.Component;

public partial class vboard_component_board_template_default_list_sub_category : BoardSubPartBase
{
	private BoardCategoryCollection CurrentCategoryCollection;

	 protected void Page_Init(Object sender, EventArgs e)
	 {
		 this.CurrentCategoryCollection = (BoardCategoryCollection)Page.Items["CurrentCategoryCollection"];
	 }

	protected void Page_Load(object sender, EventArgs e)
	{
		this.CurrentCategoryCollection.Insert(0, BoardCategory.GetTotalityCategory(base.CurrentBoard.ComponentID,
			GetLocalResourceObject("Category_TotalityCategory_Text").ToString(),
			GetLocalResourceObject("Category_TotalityCategory_ImageUrl").ToString()));

		CategoryRepeater.DataSource = this.CurrentCategoryCollection;
		CategoryRepeater.DataBind();
	}

	protected void CategoryRepeater_ItemDataBound(Object sender, RepeaterItemEventArgs e)
	{
		if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
		{
			BoardCategory currentCategory = (BoardCategory)e.Item.DataItem;

			HyperLink CategoryHyperLink = (HyperLink)e.Item.FindControl("CategoryHyperLink");

			String stringFormat = "";

			if (BoardParameters.CategoryID == currentCategory.CategoryID)
				stringFormat = GetLocalResourceObject("Category_SelectedCategoryFormat").ToString();
			else
				stringFormat = GetLocalResourceObject("Category_Format").ToString();

			CategoryHyperLink.Text = String.Format(stringFormat, currentCategory.Name, currentCategory.ThreadCount);
			CategoryHyperLink.NavigateUrl = BoardUtil.GetBoardUrl(BoardPart.List, 0, currentCategory.CategoryID, "", "", 0, 0);

			if (currentCategory.HasIconImage)
				CategoryHyperLink.ImageUrl = currentCategory.IconImageUrl;
		}
	}
}
